package com.yunmang.activity.fache;

import android.support.design.widget.TabLayout;
import android.support.v4.view.ViewPager;
import android.support.v7.widget.Toolbar;
import android.view.View;

import com.yunmang.R;
import com.yunmang.activity.BaseActivity;
import com.yunmang.adapter.MyPagerAdapter;
import com.yunmang.fragment.BaseFragment;
import com.yunmang.fragment.PiciFragment2;
import com.yunmang.fragment.PiciFragment3;
import com.yunmang.fragment.PiciListFragment;
import com.yunmang.view.MyViewPager;

import java.util.ArrayList;
import java.util.List;

import butterknife.ButterKnife;
import butterknife.InjectView;

/**
 * Created by Administrator on 2017/5/26.
 */
public class PiciDetailActivity extends BaseActivity {
    @InjectView(R.id.toolbar)
    Toolbar mToolbar;
    @InjectView(R.id.tabLayout)
    TabLayout tabLayout;
    @InjectView(R.id.viewPager)
    ViewPager viewPager;
    private List<BaseFragment> fragmentList;
    @Override
    public int getLayoutId() {
        return R.layout.activity_pici_detail;
    }

    @Override
    public void initView() {
        ButterKnife.inject(this);
        initToolbar();
    }

    private void initToolbar() {
        setSupportActionBar(mToolbar);
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        getSupportActionBar().setTitle("批次明细");
        mToolbar.setNavigationIcon(R.mipmap.ic_back);
        mToolbar.setNavigationOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                finish();
            }
        });
    }

    @Override
    public void initData() {
        fragmentList = new ArrayList<>();
        fragmentList.add(new PiciListFragment());
        fragmentList.add(new PiciFragment2());
        fragmentList.add(new PiciFragment3());
        viewPager.setAdapter(new MyPagerAdapter(getSupportFragmentManager(), fragmentList,true));
        tabLayout.setupWithViewPager(viewPager);
        tabLayout.setTabMode(TabLayout.MODE_FIXED);
    }
}
